package com.biz.primus.ms.adv.dao.po;

import java.time.LocalDateTime;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import com.biz.primus.model.adv.enums.AdType;
import com.biz.primus.model.adv.vo.LocalSourceSerizable;
import com.biz.primus.ms.base.jpa.po.BaseEntity;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 广告
 *
 * @author jun.liu
 * @date 2017-09-18
 */
@Entity
@Table(name = "ad_advertisement")
@Data
@EqualsAndHashCode(callSuper=true)
public class Advertisement extends BaseEntity implements LocalSourceSerizable {

    /**
     * 标题
     */
    @Column(name = "title", length = 200)
    private String title;

    /**
     * 广告类型
     */
    @Column(length = 30, nullable = false)
    @Enumerated(EnumType.STRING)
    private AdType atype;

    /**
     * 来源路径 如图片 视频的路径
     */
    @Column(name = "source_path", length = 200)
    private String sourcePath;

    /**
     * 起始日期
     */
    @Column(name="begin_date", length = 20, nullable = false)
    private LocalDateTime beginDate;

    /**
     * 结束日期
     */
    @Column(name="end_date", length = 20, nullable = false)
    private LocalDateTime endDate;

    /**
     * 停留多少秒(启动页使用)
     */
    @Column
    private Integer second;

    /**
     * 链接地址 跳转的地址
     */
    @Column(name="url", length = 100)
    private String url;

    /**
     * 广告位
     */
    @JoinColumn(name = "ad_position_id")
    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    private AdPosition adPosition;

    /**
     * geo 区域是否为全国
     */
    @Column
    private boolean countryStatus = false;

    /**
     * 当前资源支持的geoId字符串，以逗号间隔
     */
    @Column(name="supported_geo_id", length = 1000)
    private String supportedGeoId;

}
